<?php

namespace app\api\model\hospital;

use think\Model;


class HospitalDiscount extends Model
{

    

    

    // 表名
    protected $name = 'hospital_discount';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text'
    ];
    

    
    public function getTypeList()
    {
        return ['10' => __('Type 10'), '20' => __('Type 20')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ?: ($data['type'] ?? '');
        $list = $this->getTypeList();
        return $list[$value] ?? '';
    }


    public function hospital()
    {
        return $this->hasOne('\app\api\model\hospital\Hospital', 'id', 'hospital_id');
    }

    public function goods(){
        return $this->hasOne('\app\api\model\goods\Goods', 'id', 'goods_id');
    }

}
